home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / trains.lha / trains.c next >
C/C++ Source or Header  |  1994-02-26  |  5KB  |  145 lines

  1. /* ************************************************************************
  2. *   File: trains.c                                                        *
  3. *  Usage: Transporter handling functions for CircleMUD                    *
  4. *     By: Carl Tashian [Guru Meditation]                                  *
  5. *         [tashiacm@ctrvax.vanderbilt.edu]                                *
  6. ************************************************************************ */
  7.  
  8. #include <stdio.h>
  9. #include <string.h>
  10. #include <ctype.h>
  11. #include <sys/types.h>
  12. #include <time.h>
  13.  
  14. #include "structs.h"
  15. #include "utils.h"
  16. #include "comm.h"
  17. #include "interpreter.h"
  18. #include "handler.h"
  19. #include "db.h"
  20. #include "limits.h"
  21.  
  22. /*   external vars  */
  23. extern struct room_data *world;
  24. int transpath = 0;
  25. char curstat1[100], curstat2[100];
  26.  
  27. void enter_stat(int station, char wherefrom[100], int which);
  28. void leave_stat(int station, char whereto[100], int which);
  29.  
  30. void train_upd(void)
  31. {
  32. int wdoor, edoor, station[5];
  33. station[0] = real_room(3069); /* room of Midgaard Station */
  34. station[1] = real_room(3142); /* room of South Midgaard Station */
  35. station[2] = real_room(12068); /* room of Rome Station */
  36. station[3] = real_room(9941); /* room of Wayhouse Station */
  37. station[4] = real_room(17153); /* room of Kerofk station */
  38. wdoor = 3; /* west dir number */
  39. edoor = 1; /* east dir number */
  40. switch (transpath)
  41. {
  42. case 0:
  43.    /* leave from VVVVVV to  VVVVVV */
  44.    leave_stat(station[0], "Southern Midgaard", 1);
  45.    leave_stat(station[3], "Kerofk Station", 2);
  46.    break;
  47. case 1:
  48.    /* enter station VVVV from VVVV */
  49.    enter_stat(station[1], "Midgaard Station", 1);
  50.    enter_stat(station[4], "Wayhouse Station", 2);
  51.    break;
  52. case 2:
  53.    leave_stat(station[1], "Rome Station", 1);
  54.    leave_stat(station[4], "Midgaard Station", 2);
  55.    break;
  56. case 3:
  57.    enter_stat(station[2], "Southern Midgaard", 1);
  58.    enter_stat(station[0], "Kerofk Station", 2);
  59.    break;
  60. case 4:
  61.    leave_stat(station[2], "Wayhouse Station", 1);
  62.    leave_stat(station[0], "Southern Midgaard", 2);
  63.    break;
  64. case 5:
  65.    enter_stat(station[3], "Rome Station", 1);
  66.    enter_stat(station[1], "Midgaard Station", 2);
  67.    break;
  68. case 6:
  69.    leave_stat(station[3], "Kerofk Station", 1);
  70.    leave_stat(station[1], "Rome Station", 2);
  71.    break;
  72. case 7:
  73.    enter_stat(station[4], "Wayhouse Station", 1);
  74.    enter_stat(station[2], "Southern Midgaard", 2);
  75.    break;
  76. case 8:
  77.    leave_stat(station[4], "Midgaard Station", 1);
  78.    leave_stat(station[2], "Wayhouse Station", 2);
  79.    break;
  80. case 9:
  81.    enter_stat(station[0], "Kerofk Station", 1);
  82.    enter_stat(station[3], "Rome Station", 2);
  83.    break;
  84. /* then back to the case 0 again.. */
  85. default:
  86.    log("SYSERR: Big problem with the transporter!");
  87.    break;
  88. } /* switch */
  89. transpath++;
  90. if (transpath==6) transpath=0;
  91. return;
  92. } /* funct */
  93.  
  94. void enter_stat(int station, char wherefrom[100],
  95.                 int which)
  96. {
  97. int transroom, wdoor, edoor;
  98. char buf[MAX_STRING_LENGTH];
  99. char whereat[100];
  100. if (which == 1) {
  101.   transroom = real_room(3070); /* this MUST be the transporter itself (room) */
  102.   strcpy(whereat, curstat1);
  103.   }
  104. if (which == 2) {
  105.   strcpy(whereat, curstat2);
  106.   transroom = real_room(3072); /* transporter room 2 */
  107.   }
  108. wdoor = 3; /* west dir number */
  109. edoor = 1; /* east dir number */
  110. world[transroom].dir_option[wdoor]->to_room = station;
  111. world[station].dir_option[edoor]->to_room = transroom;
  112. send_to_room("The transporter slows to a halt, and the doors to your west open..\n\r", transroom);
  113. sprintf(buf, "The conductor announces, 'Welcome to %s'\n\r", whereat);
  114. send_to_room(buf, transroom);
  115. sprintf(buf, "Without a sound, the transporter from %s pulls into\n\r", wherefrom);
  116. send_to_room(buf, station);
  117. send_to_room("the station, and the doors to your east open.\n\r", station);
  118. return;
  119. }
  120.  
  121. void leave_stat(int station, char whereto[100], int which)
  122. {
  123. int transroom, wdoor, edoor;
  124. char buf[MAX_STRING_LENGTH];
  125.  
  126. if (which == 1) {
  127.   strcpy(curstat1, whereto);
  128.   transroom = real_room(3070); /* this MUST be the transporter itself (room) */
  129.   }
  130. if (which == 2) {
  131.   strcpy(curstat2, whereto);
  132.   transroom = real_room(3072); /* train 2 */
  133.   }
  134. wdoor = 3; /* west dir number */
  135. edoor = 1; /* east dir number */
  136.  
  137. world[transroom].dir_option[wdoor]->to_room = NOWHERE;
  138. world[station].dir_option[edoor]->to_room = NOWHERE;
  139. sprintf(buf, "The conductor announces, 'Next stop: %s'\n\r", whereto);
  140. send_to_room(buf, transroom);
  141. send_to_room("The transporter doors close, and the transporter starts it's journey\n\r", transroom);
  142. send_to_room("The transporter doors close, and it instantly disappears into the tunnel..\n\r", station);
  143. return;
  144. } /* move_from */
  145.